/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package xmlconvert.internalStructure;

import java.util.List;
import org.apache.log4j.Logger;

/**
 *
 * @author ash
 */
public class Record implements Member {
    
    private static Logger LOG = Logger.getLogger(Record.class);
    
    private String name;
    private List FieldContainer;
    
    public boolean isGroup(){
        return false;
    }
    
    
    public String getName(){
        return name;
    }
    
    public static Record createRecord(String name){
        try{
            Verifications.verifyRecord(name);
        } catch (VerificationException ve){
            LOG.warn("Cannot create record. " + ve.getMessage());
            return null;
        }
        
        return new Record(name);
    }
    
    private Record(String n){
        name=n;
    }
    
    public void addField(Field f){
        FieldContainer.add(f);
        if (LOG.isDebugEnabled()){
            LOG.debug("Field added to record [" + name + "]: [" + f.getName() + "].");
        }
    }
    
    public int getSize(){
        return FieldContainer.size();
    }
    
    public Field item(int n){
        return (Field) FieldContainer.get(n);
    }
    
}
